const { ListToNode, NodeToList, ListNode, timeL } = require("../utils.js");
/**
 * @param {string[]} strs
 * @return {string[][]}
 */
var groupAnagrams = function (strs) {
  let map = {};
  for (let i = 0; i < strs.length; i++) {
    let key = strs[i]
      .split("")
      .sort()
      .join("");
    map[key] = map[key] || [];
    map[key].push(strs[i]);
  }
  return Object.values(map);
};
let strs = ["eat", "tea", "tan", "ate", "nat", "bat"];

timeL(groupAnagrams, [strs]);
